using System;
using Newtonsoft.Json;

namespace Tools.ExcelToJson.Editor
{
    internal static class JsonUtils
    {
        public static object FromJson(string json, Type type)
        {
            var generatedType = JsonConvert.DeserializeObject(json, type);
            return Convert.ChangeType(generatedType, type);
        }

        public static string ToJson(object value)
        {
            return JsonConvert.SerializeObject(value, Formatting.Indented);
        }
    }
}